package com.h2cloud.aspect.cglibAop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * @author: wulongkai
 * @create: 2022-10-11 11:22
 **/
@Component
public class MailService {

    @Autowired
    UserService userService;

    @Autowired
    iService userServiceV2;

    public String sendMail() {
        // 不要直接访问UserService的字段:
        ZoneId zoneId = userService.zoneId;
//         ZoneId zoneId = userService.getFinalZoneId();
//        ZoneId zoneId = userService.getZoneId();
        String dt = ZonedDateTime.now(zoneId).toString();
        return "Hello, it is " + dt;
    }

    public String sendMailV2() {
        // 不要直接访问UserService的字段:
        ZoneId zoneId = userServiceV2.zoneId;
//         ZoneId zoneId = userServiceV2.getFinalZoneId();
//        ZoneId zoneId = userServiceV2.getZoneId();
        String dt = ZonedDateTime.now(zoneId).toString();
        return "Hello, it is " + dt;
    }
}
